var folders = [];
var fileList;
var files = [];
var pindex = 0;

var folderId = "myroot";
var folderText="根目录";
$(function(){
	folders.push({id:"myroot",dir:"根目录"});
	
	
});

function deletefiles(){
	if(!confirm("确定要删除所选文件?")){
		return ;
	}
	if(files.length==0){
		alert("请选择文件!");
		return;
	}
	var pstr="";
	var j=0;
	$.each(files, function(idx, file) {
		pstr += "files[" + (pindex++) + "]=" + file.id+"&";
		++j;
	});
	
	doSubmit("fileserver/file/translate-file!removebyid",pstr,reloadjqGrid);	
}

function reloadjqGrid(){
	if(typeof(mygrid)!='undefined'){
		mygrid.trigger("reloadGrid");	
	}
	
}

function moveToFolder(){
	   if(files.length==0){	   
	    	 
	    	 return;
	     }
	     var ps = "folder.id="+folderId;
	     $.each(files,function(idx,file){
	    	 ps+="&files["+(pindex++)+"]="+file.id;
	     });	
	     doSubmit("fileserver/file/translate-file!changefolder",ps,folderchanged);
	
}

function folderchanged(){
	files=[];
	$("#fileList").empty();	    
}




function checkFile(id, text, chk) {
	selectFiles[id] = chk;	
}
function removeMe(id) {
	if(!confirm("确认要删除此文件?")){
		return ;
	}
	doSubmit("fileserver/file/translate-file!removebyid","files[0]=" + id,function(){
		 mygrid.trigger("reloadGrid");
	});
	
}